package com.fanqiechaodan.memento;

import lombok.Data;

/**
 * @author fanqiechaodan
 * @Classname Role
 * @Description 发起人类
 */
@Data
public class Role {

    /**
     * 攻击力
     */
    private int attack;

    /**
     * 防御力
     */
    private int defense;

    /**
     * 生命值
     */
    private int hp;

    public Role(int attack, int defense, int hp) {
        this.attack = attack;
        this.defense = defense;
        this.hp = hp;
    }

    /**
     * 将当前对象储存值Memento中
     * @return
     */
    public Memento save(){
        return new Memento(attack,defense,hp);
    }

    /**
     * 从memento中获取状态;并恢复到当前状态
     * @param memento
     */
    public void restore(Memento memento){
        attack = memento.getAttack();
        defense = memento.getDefense();
        hp = memento.getHp();
    }
}
